package cn.q3c.parse.commons.wordpress;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

public class Post {

	// 分类，可以是自定义名
	private String post_type;
	// 发布状态 publish 
	private String post_status;
	// 标题
	private String post_title;
	// 摘要
	private String post_excerpt;
	// 正文
	private String post_content;
	public void setPost_content(String post_content) {
		this.post_content = post_content;
	}

	// 自定义字段
	private Object[] custom_fields = null;
	// 分类
	private Map<String, Object> terms_names = null;

	public String getPost_type() {
		return post_type;
	}

	public void setPost_type(String post_type) {
		this.post_type = post_type;
	}

	public String getPost_status() {
		return post_status;
	}

	public void setPost_status(String post_status) {
		this.post_status = post_status;
	}

	public String getPost_title() {
		return post_title;
	}

	public void setPost_title(String post_title) {
		this.post_title = post_title;
	}

	public String getPost_excerpt() {
		return post_excerpt;
	}

	public void setPost_excerpt(String post_excerpt) {
		this.post_excerpt = post_excerpt;
	}

	public String getPost_content() {
		return post_content;
	}

	public Object[] getCustom_fields() {
		return custom_fields;
	}

	public void setCustom_fields(Object[] custom_fields) {
		this.custom_fields = custom_fields;
	}

	public Map<String, Object> getTerms_names() {
		return terms_names;
	}

	public void addCustomField(String key, String value) {
		Map<String, String> custom_field = new HashMap<String, String>();
		custom_field.put("key", key);
		custom_field.put("value", value);
		custom_fields = ArrayUtils.add(custom_fields, custom_field);
	}

	public void addTerm(String key, Object[] value) {
		if (terms_names == null) {
			terms_names = new HashMap<String, Object>();
		}

		if (!ArrayUtils.isEmpty(value)) {
			terms_names.put(key, value);
		}
	}

	public String toString() {
		return ReflectionToStringBuilder.toString(this);
	}
}